<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>platform.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_useragent_platform.js.html">platform.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2010 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Utilities for getting details about the user&#39;s platform.
<a name="line17"></a> */
<a name="line18"></a>
<a name="line19"></a>goog.provide(&#39;goog.userAgent.platform&#39;);
<a name="line20"></a>
<a name="line21"></a>goog.require(&#39;goog.userAgent&#39;);
<a name="line22"></a>
<a name="line23"></a>
<a name="line24"></a>/**
<a name="line25"></a> * Detects the version of Windows or Mac OS that is running.
<a name="line26"></a> *
<a name="line27"></a> * @private
<a name="line28"></a> * @return {string} The platform version.
<a name="line29"></a> */
<a name="line30"></a>goog.userAgent.platform.determineVersion_ = function() {
<a name="line31"></a>  var version = &#39;&#39;, re;
<a name="line32"></a>  if (goog.userAgent.WINDOWS) {
<a name="line33"></a>    re = /Windows NT ([0-9.]+)/;
<a name="line34"></a>    var match = re.exec(goog.userAgent.getUserAgentString());
<a name="line35"></a>    if (match) {
<a name="line36"></a>      return match[1];
<a name="line37"></a>    } else {
<a name="line38"></a>      return &#39;0&#39;;
<a name="line39"></a>    }
<a name="line40"></a>  } else if (goog.userAgent.MAC) {
<a name="line41"></a>    re = /10[_.][0-9_.]+/;
<a name="line42"></a>    var match = re.exec(goog.userAgent.getUserAgentString());
<a name="line43"></a>    // Note: some old versions of Camino do not report an OSX version.
<a name="line44"></a>    // Default to 10.
<a name="line45"></a>    return match ? match[0].replace(/_/g, &#39;.&#39;) : &#39;10&#39;;
<a name="line46"></a>  } else if (goog.userAgent.ANDROID) {
<a name="line47"></a>    re = /Android\s+([^\);]+)(\)|;)/;
<a name="line48"></a>    var match = re.exec(goog.userAgent.getUserAgentString());
<a name="line49"></a>    return match ? match[1] : &#39;&#39;;
<a name="line50"></a>  } else if (goog.userAgent.IPHONE || goog.userAgent.IPAD) {
<a name="line51"></a>    re = /(?:iPhone|CPU)\s+OS\s+(\S+)/;
<a name="line52"></a>    var match = re.exec(goog.userAgent.getUserAgentString());
<a name="line53"></a>    // Report the version as x.y.z and not x_y_z
<a name="line54"></a>    return match ? match[1].replace(/_/g, &#39;.&#39;) : &#39;&#39;;
<a name="line55"></a>  }
<a name="line56"></a>
<a name="line57"></a>  return &#39;&#39;;
<a name="line58"></a>};
<a name="line59"></a>
<a name="line60"></a>
<a name="line61"></a>/**
<a name="line62"></a> * The version of the platform. We only determine the version for Windows and
<a name="line63"></a> * Mac, since it doesn&#39;t make much sense on Linux. For Windows, we only look at
<a name="line64"></a> * the NT version. Non-NT-based versions (e.g. 95, 98, etc.) are given version
<a name="line65"></a> * 0.0
<a name="line66"></a> * @type {string}
<a name="line67"></a> */
<a name="line68"></a>goog.userAgent.platform.VERSION = goog.userAgent.platform.determineVersion_();
<a name="line69"></a>
<a name="line70"></a>
<a name="line71"></a>/**
<a name="line72"></a> * Whether the user agent platform version is higher or the same as the given
<a name="line73"></a> * version.
<a name="line74"></a> *
<a name="line75"></a> * @param {string|number} version The version to check.
<a name="line76"></a> * @return {boolean} Whether the user agent platform version is higher or the
<a name="line77"></a> *     same as the given version.
<a name="line78"></a> */
<a name="line79"></a>goog.userAgent.platform.isVersion = function(version) {
<a name="line80"></a>  return goog.string.compareVersions(
<a name="line81"></a>      goog.userAgent.platform.VERSION, version) &gt;= 0;
<a name="line82"></a>};
</pre>


</body>
</html>
